package com.lau.vo;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author:Lau
 * @create: 2022-12-15 11:32
 * @Description:
 */
@Data
@AllArgsConstructor
public class ResultData<T> {

    /**
     * 状态类型
     */
    public enum Type
    {
        /**
         * 失败：0
         */
        FAILURE(0),

        /**
         * 成功：1
         */
        SUCCESS(1);
        private final int value;

        Type(int value)
        {
            this.value = value;
        }

        public int value()
        {
            return this.value;
        }
    }


    private Type status = Type.FAILURE;

    private T data;

    private String msg;


    public static <T> ResultData<T> success() {
        return new ResultData(Type.SUCCESS,null,"操作成功");
    }

    public static <T> ResultData<T> success(String msg) {
        return new ResultData(Type.SUCCESS,null,msg);
    }

    public static <T> ResultData<T> success(String msg, T data) {
        return new ResultData(Type.SUCCESS, data,msg);
    }

    public static <T> ResultData<T> error() {
        return new ResultData(Type.FAILURE,null,"操作失败");
    }

    public static <T> ResultData<T> error(String msg) {
        return new ResultData(Type.FAILURE,null,msg);
    }

    public static <T> ResultData<T> error(String msg, T data) {
        return new ResultData(Type.FAILURE, data,msg);
    }





}
